package com.pojo.order.service;


import com.pojo.order.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.*;

@Service
public class UserService {

    private static final Map<Long, User> ALL_USERS = new HashMap<Long, User>();

    static {
        // 模拟数据库，构造测试数据
        ALL_USERS.put(1L, new User(1L, 123L));
        ALL_USERS.put(2L, new User(2L, 123L));
        ALL_USERS.put(3L, new User(3L, 123L));
    }

//    @Autowired
//    private ItemService itemService;


    public User queryUserById(Long userId) {
        return ALL_USERS.get(userId);
    }


//    public Order queryOrderByIdx(String orderId) {
//        Order order = ORDER_DATA.get(orderId);
//        if (null == order) {
//            return null;
//        }
//        List<OrderDetail> orderDetails = order.getOrderDetails();
//        for (OrderDetail orderDetail : orderDetails) {
//            // 通过商品微服务查询商品详细数据
//            User item = this.itemService.queryItemById(orderDetail.getItem()
//                    .getId());
//            if (null == item) {
//                continue;
//            }
//            orderDetail.setItem(item);
//        }
//
//        return order;
//    }

}
